<?
	$db = GetDefaultConnection();

/*
	$q = date('Y-m-d');

	$queryarry = array(
		'ORDER_DATE' => $q,
	);

	$query=makeWhereQry($queryarry);

	if ($query != "")
		$where .= " and ". $query;
*/
	$where = " and ORDER_CODE not in (select distinct ORDER_CODE from TB_TRADE)";
	$sql = sprintf("SELECT * "
					.", (select JBNH_NAME FROM TB_JBNH WHERE JBNH_SEQ=a.JBNH_SEQ) as JBNH_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='B' AND CODE_CODE1=4 AND a.ORDER_TYPE=CODE_CODE2) as ORDER_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='A' AND CODE_CODE1=a.ORDER_ITEM1 AND CODE_CODE2=0) as ORDER_ITEM1_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='A' AND CODE_CODE1=a.ORDER_ITEM1 AND CODE_CODE2=a.ORDER_ITEM2) as ORDER_ITEM2_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='B' AND CODE_CODE1=a.ORDER_GRADE1 AND CODE_CODE2=a.ORDER_GRADE2) as ORDER_GRADE2_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='B' AND CODE_CODE1=a.ORDER_STANDARD1 AND CODE_CODE2=a.ORDER_STANDARD2) as ORDER_STANDARD2_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='C' AND CODE_CODE1=a.ORDER_DESTINATION1 AND CODE_CODE2=0) as ORDER_DESTINATION1_NAME "
					." FROM TB_ORDER a Where 1=1 %s order by ORDER_SEQ desc "
					, $where);
	$list = $db->queryList($sql)
?>

<?
	if ($list->getLength() == 0)
	{
?>
                <tr>
                	<td colspan=14>등록된 목록이 없습니다.</td>
                </tr>
<?
	}
	else
	{
		while ($list->hasNext())
		{
			$row = & $list->next();
			$order_date = $row->getString('ORDER_DATE');
			$order_seq = $row->getNumber('ORDER_SEQ');
			$jbnh_name = $row->getString('JBNH_NAME');
			$order_name = $row->getString('ORDER_NAME');
			$order_item1_name = $row->getString('ORDER_ITEM1_NAME');
			$order_item2_name = $row->getString('ORDER_ITEM2_NAME');
			$order_grade2_name = $row->getString('ORDER_GRADE2_NAME');
			$order_standard2_name = $row->getString('ORDER_STANDARD2_NAME');
			$order_weight2 = $row->getNumber('ORDER_WEIGHT2');
			$order_number = $row->getNumber('ORDER_NUMBER');
			$order_total = $row->getNumber('ORDER_TOTAL');
			$order_arrivaldate = $row->getString('ORDER_ARRIVALDATE');
			$order_arrivaltime = $row->getString('ORDER_ARRIVALTIME');
			$order_destination1_name = $row->getString('ORDER_DESTINATION1_NAME');
?>
				<tr>
                	<td><input type="checkbox" id="seq" name="seq" value="<?=$order_seq?>" title="수정/삭제시 체크" onclick="fnview(this.value);" <?=($seq==$order_seq)?"checked":""?> /></td>
                	<td class="day_cal"><?=$order_date?></td>
                    <td><?=$jbnh_name?></td>
					<td><?=$order_name?></td>
                    <td><?=$order_item1_name?></td>
                    <td><?=$order_item2_name?></td>
                    <td><?=$order_grade2_name?></td>
                    <td><?=$order_standard2_name?></td>
                    <td><?=$order_weight2?>kg</td>
                    <td><?=$order_number?>개</td>
                    <td><?=$order_total?>kg</td>
                    <td><?=$order_destination1_name?></td>
					<td><?=$order_arrivaldate?></td>
                    <td><?=$order_arrivaltime?>시</td>
                </tr>
<?
			}
		}
?>

